package com.example.java2mysql2.instrastructure;

import com.example.java2mysql2.domain.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

@Repository
public interface JpaStudent extends JpaRepository<Student,Long> {
    Student findByStudentCode(String code);

    List<Student> findByTeam_TeamCode(String teamCode);
  //  @Transactional
    void deleteByStudentCode(String code);

    @Query(value ="select * from student s left join team t on s.team_code = t.team_code where t.team_position like ?1%" ,nativeQuery = true)
    List<Student> findLikeNameNative(String name);
    @Query(value = "select s from Student s left join fetch s.team t where t.teamPosition like ?1%")
    List<Student> findLikeName(String name);


}
